using System;
using PetShop.Infrastructure.Exceptions;

namespace PetShop.Domain.Model {

	
	
	
	[Serializable]
	public class Account {

		
		private string _UserId;
		private string _Password;
		private string _Email;
		private AddressInfo _Address;
		private Nullable<System.Int32> _BannerOpt;
        private Category _FavCategory;
        private System.String _LangPref;
        private Nullable<System.Int32> _MyListOpt;
        private bool _showFavorites;
		private bool _showBanners;

    
        public  Account()
        {
        }

    

        public Account(string userId, string password, string email, AddressInfo address, string language, Category category, bool showFavorites, bool showBanners)
        {
            this._UserId = userId;
            this._Password = password;
            this._Email = email;
            this._Address = address;
            this._LangPref = language;
            this._FavCategory = category;
            this._MyListOpt = System.Convert.ToInt32(showFavorites);
            this._BannerOpt = System.Convert.ToInt32(showBanners);
           
        }


        public AddressInfo Address
        {
            get { return _Address; }
            set { _Address = value; }
        }


        public virtual Nullable<int> BannerOpt
        {
            get
            {
                return _BannerOpt;
            }
            set
            {
                _BannerOpt = value;
            }
        }

      
        public virtual string Email
        {
            get
            {
                return _Email;
            }
            set
            {
                if (value == null)
                {
                    throw new BusinessException("EmailRequired", "Email must not be null.");
                }
                _Email = value;
            }
        }

        public virtual Category FavCategory
        {
            get
            {
                return _FavCategory;
            }
            set
            {
                _FavCategory = value;
            }
        }

        public virtual string UserId
        {
            get
            {
                return _UserId;
            }
            set
            {
                _UserId = value;
            }
        }

        public virtual string LangPref
        {
            get
            {
                return _LangPref;
            }
            set
            {
                if (value == null)
                {
                    throw new BusinessException("LangPrefRequired", "LangPref must not be null.");
                }
                _LangPref = value;
            }
        }


        public virtual int? MyListOpt
        {
            get
            {
                return _MyListOpt;
            }
            set
            {
                _MyListOpt = value;
            }
        }

        public virtual string Password
        {
            get
            {
                return _Password;
            }
            set
            {
                if (value == null)
                {
                    throw new BusinessException("PasswordRequired", "Password must not be null.");
                }
                _Password = value;
            }
        }


		public bool IsShowFavorites {
			get {
                if (this._MyListOpt.HasValue==false )
                {
                    return false;
                }
                else if (_MyListOpt == 0)
                {
                    return false;
                }
                else
                {
                    return true;
                }
               
            }
		}
		public bool IsShowBanners {
            get
            {
                if (!(this._BannerOpt.HasValue) || this._BannerOpt==0)
                {
                    _showFavorites= false;
                }
                else
                {
                    _showFavorites =true;
                }
                return _showFavorites;
            }
		}

        public void Validate()
        {
            if (this.Password.Length < 5)
                throw new BusinessException("ACC003", "Password must contain more than 5 characters.");

        }


	}
}